<template>
	<view class="page">
		<view class="list">
			<view class="listX" v-for="(v, k) in listData" :key="k">
				<view class="listX_le">
					<view class="img">
						<image :src="v.head_img" mode="aspectFill" :lazy-load="true"></image>
					</view>
				</view>
				<view class="listX_ri">
					<view>{{v.user_nickname}}</view>
					<view>注册于{{v.create_time}}</view>
				</view>
			</view>
		</view>
		<view v-if="listData.length == 0" style="padding: 20rpx 0;">
			<u-empty text="没有更多了" mode="list"></u-empty>
		</view>
		<view style="padding: 20rpx 0;">
			<u-loadmore v-if="last_page > 1" :status="status" :icon-type="iconType" :load-text="loadText" />
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				listData: [],
				last_page: 1,
				page: 1,
				refresh: false,
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '没有更多了'
				}
			}
		},
		methods: {
			recordsInfo() {
				this.$api.post(global.apiUrls.shareRecord, {
					
				}).then(res => {
					// console.log(res)
					uni.hideLoading()
					uni.stopPullDownRefresh()
					if(res.data.code == 1) {
						this.last_page = res.data.data.last_page
						if(this.refresh) {
							this.listData = res.data.data.data
						} else {
							this.listData = this.listData.concat(res.data.data.data)
						}
					}
				})
			}
		},
		onShow() {
		  uni.showLoading({
		  	title: '加载中'
		  })
		  this.page = 1
		  this.refresh = true
		  this.recordsInfo()
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1
			this.refresh = true
			this.recordsInfo()
		},
		// 上拉加载
		onReachBottom() {
			if (this.page >= this.last_page) return;
			this.status = 'loading';
			this.page++;
			this.refresh = false
			setTimeout(() => {
		
				if (this.page >= this.last_page) this.status = 'nomore';
				else this.status = 'loading';
				this.recordsInfo()
			}, 500)
		},
	}
</script>

<style lang="scss" scoped>
  .page{
    min-height: 100vh;
    background-color: #FFFFFF;
	color: #333333;
	.list {
		padding: 0 32rpx;
		.listX {
			padding: 32rpx 0;
			border-bottom: 1rpx solid #f2f2f1;
			display: flex;
			.listX_le {
				flex: 2;
				.img {
					width: 108rpx;
					height: 108rpx;
					border-radius: 50%;
					image {
						width: 100%;
						height: 100%;
						border-radius: 50%;
					}
				}
				
			}
			.listX_ri {
				flex: 8;
				padding-top: 8rpx;
				view:first-child {
					font-size: 32rpx;
					font-weight: bold;
					margin-bottom: 16rpx;
				}
				view:last-child {
					font-size: 24rpx;
					color: #999999;
				}
			}
		}
	}
  }
  
</style>
